<?php
class Modules_Cms_SubClass extends ME_DAL_FileCacheModule
{
	
	protected $_depend = array();

	/**
	* 过期时间
	* @var integer
	*/
	protected $_expire = 3600;

    private $db;
    private function loadDb()
    {
        $this->db = Db_Admin::instance();
    }
	
	public function refresh(array $param = array())
	{
        $classId = (int)$param['classId'];
        
        $this->loadDb();
        
        if(!$classId){
            $sql = "select distinct classId from cms_subclass ";
            $arr = $this->db->getAll($sql);
            if($arr){
                foreach($arr as $a){
                    $this->refresh(array("classId" => $a['classId']));
                }
            }
            return true;
        }else{
            //取得所有的频道
            $listData = Libs_Cms_Class::getSubClassArr(array('classId' => $classId));
            $cacheData = array();
            if($listData){
                foreach($listData as $d){
                    $cacheData[$d['id']] = $d;
                }
            }
            $this->set(array('classId'=>$classId),$cacheData);
            return true;
        }
	}
}